Skip to content

fix(web): keep the right panel open when its last tab closes - #7732

Open
moazessam376-dev wants to merge 1 commit into
pingdotgg:mainfrom
moazessam376-dev:fix/right-panel-keeps-empty-state-on-last-tab-close
Open

fix(web): keep the right panel open when its last tab closes#7732
moazessam376-dev wants to merge 1 commit into
pingdotgg:mainfrom
moazessam376-dev:fix/right-panel-keeps-empty-state-on-last-tab-close

Conversation

@moazessam376-dev

@moazessam376-dev moazessam376-dev commented Aug 20, 2026

Copy link
Copy Markdown

What Changed

Closing the last tab in the right panel no longer collapses the panel. It now falls back to the empty-state picker, which is the same state the panel already shows when you toggle it open on a thread that has no tabs yet.

The change is in apps/web/src/rightPanelStore.ts. closeSurface, closeTerminal, and closeAllSurfaces each forced isOpen to false once the last surface was removed. They now go through one helper, isOpenAfterClose, so panel visibility is owned by close and toggleVisibility rather than by tab count.

Fixes #7727.

Why

The empty state this falls back to already exists and is fully built: RightPanelEmptyState in apps/web/src/components/RightPanelTabs.tsx, added in #6258. RightPanelTabs even hides the add-surface + button when there are no surfaces, because the picker cards replace it, and the panel is gated only on isOpen and not on surface count. The UI already supported this state; the store was the only thing preventing a closed tab from reaching it.

It is most noticeable with files, because openFile deliberately replaces the standalone explorer surface with the file tab (tested in rightPanelStore.test.ts). Open the explorer, open a file, close it, and the panel disappears even though you never dismissed the explorer yourself. Closing a lone terminal, diff, or browser tab did the same.

Two deliberate boundaries:

  1. reconcileFileSurfaces still closes the panel when the workspace goes away. That path reacts to surfaces becoming invalid, not to a user closing a tab.
  2. The shared panel on the pull-request list keeps the old behavior, since it renders only while a change request is selected and has no picker to fall back to. Leaving it open would show a blank panel, so isOpenAfterClose excludes it via the existing isPullRequestsPanelKey check.

Three existing tests asserted the old collapse behavior and are updated here. They predate #6258, which built the empty state but did not revisit the store. Three tests are added: closing a file opened from the explorer, the pull-request panel exception, and a hidden panel staying hidden.

This is client state in apps/web with no platform branching, so it applies to the browser app and to the desktop app on Windows, macOS, and Linux. apps/mobile does not use this store.

UI Changes

Before, a file open in the right panel:

Before: a file open in the right panel

Closing that one tab removes the entire panel:

Before: the panel collapsed entirely

After, same starting point:

After: a file open in the right panel

Closing the same tab now lands on the picker:

After: the empty-state picker

Testing

  • apps/web unit suite: 2653 tests across 270 files pass
  • tsgo --noEmit on apps/web passes
  • vp lint and vp fmt --check pass on both changed files

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk
Client-only panel visibility in the right-panel store; no auth, persistence version, or data-handling changes. Hidden panels and the PR-list exception are covered by tests.

Overview
Closing the last right-panel tab no longer collapses the panel. closeSurface, closeTerminal, and closeAllSurfaces now keep isOpen when a thread panel is emptied, so users land on the existing empty-state picker instead of losing the panel.

Visibility is centralized in isOpenAfterClose: a hidden panel stays hidden, and the pull-request list’s shared panel still closes when its last tab is gone (it has no picker). Workspace invalidation via reconcileFileSurfaces is unchanged.

Reviewed by Cursor Bugbot for commit 4edfc7a. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Keep right panel open when its last tab closes

  • Regular right panels now stay open and show an empty state when their last surface closes, instead of closing automatically.
  • Adds isOpenAfterClose helper in rightPanelStore.ts and applies it to closeTerminal, closeSurface, and closeAllSurfaces handlers.
  • The shared pull-requests panel is an exception: it still closes when emptied.
  • Behavioral Change: closeAllSurfaces no longer unconditionally sets isOpen=false; regular panels remain open. Reviewers should verify callers relying on panel auto-close now handle the empty state.

Macroscope summarized 4edfc7a.

Closing the last tab in the right panel collapsed the whole panel instead
of falling back to the empty-state picker.

The panel already has a first-class "open with no surfaces" state: it
renders RightPanelEmptyState, and RightPanelTabs hides the add-surface "+"
button at zero surfaces because the picker cards replace it. Toggling the
panel on a thread with no tabs is exactly that state today. But the store's
close paths set isOpen to false once the last surface went away, so the
same empty panel reached by closing a tab collapsed instead.

It is most visible with files, because openFile deliberately replaces the
standalone explorer surface with the file tab: open the explorer, open a
file, close it, and the panel disappears even though the explorer was
never dismissed. Closing a lone terminal, diff or browser tab did the same.

Panel visibility is now owned by close/toggleVisibility, not by tab count.
The pull-request list's shared panel keeps its old behaviour, since it only
renders while a change request is selected and has no empty state to fall
back to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c23511fa-f520-417e-98bb-56054a853316

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 20, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes user-facing behavior: the right panel now stays open when its last tab closes instead of closing. While the change is well-tested and self-contained, significant UI behavior changes warrant human review to validate the UX decision.

You can add or adjust custom eligibility rules. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Closing the last right-panel tab collapses the whole panel instead of falling back to the empty state

1 participant